adding mainloop system