Fixed undefined  error in exec() function