refactor safeExecution function, pep8 fix, mutable argument fix