refactor safeExecution function, pep8 fixe, mutable argument fix