cleaned up code for route writing