move import to head of script, rather than in function.  Less efficient if not needed, but easier to read