Pull out some logic from view to helper