Fix Exec function to determine the cause of failure