refactored into a class