Fixing bug in agent