refactor app and routes