Sleep in mainloop to reduce cpu consumtion