implemented main program as a class