check for modules before writing