move helper code to model refs #77