moved quering to view instead of controller