added assertion and exception