Refactor the notebook
XX try to use error function as an example