reintroduced the custom mainloop iteration

added the custom mainloop iteration again because
it performs better than custom sleep functions.