refactor some codes
fix planner's bug