updated OO code, now works