Refactor to a class