refactor to a class