main loop for monitoring