refactor to object-oriented