Fixed bug in Agent