Clean code and handle error messages