helper code from view