updated mainloop and changed parameter name.