refactor server side routes