Converted code from procedural to object-oriented