moved a few uglier lines back into the module