Update log error message
Refactored the js.