FIX Move the module definition to the top of the function