Refactored improvememt to show the error in the log