refactored non-view code