finished. added comments, and boundary error function