Added mainloop