Refactor to routes