refactored into class structure