refactor for object orientation