refactored code into a level base class