Added delay to the main loop