Critical fix - proper error handling