Add pause(long time) for agent
Correct Method waitNextMessage to remove redundant code