changed order of main function