A Replanning Algorithm for a Reactive Agent Architecture