finished refactor from procedural to oop