Remove reliance on views for logic, move to controller