refactored database calls out of user routes