refactored code, adding routes