custom mainloop added