Added a step function for the agent