moved main function