implemented assertion and exception handling. requires testing