working on main function