moved monitor loop to beginning