fixed the monitor algorithm