updated main function, calls. (WIP, not tested)