Refactor robot.erl