improved agent class