refactor so to use class