main function problem solving