Refactored additional database queries out of router