I would have put this code into a new method of EclAgent so that it could be called above...