Refactored collection controller code