Slight modification of error handling