refactor robot control