cleaned up logic in routes