change code to be OO