refactor into a class