fix the main function