API: Re-factored get_courses_main function to log and output results cleaned extra code