repaired exec-function