turn the select call into a function.