implemented the main program