cleaned up monitor code