added debug states and fixed distance to agent