attempt to get rid of 'trim_modules' function