adding sleep in main loop to reduce CPU usage