refactor into class structure