Refactored common code in ExecutePar and ExecuteSeq into a new function