Added variable sleeps to reduce cpu usage