changed previous implementation all in one file into a object oriented implementation