refactored code to several files/classes