refactor services and routes