Planning algorithm