tried to clean up large function in the repo routes