Add an assertion function and do some try/catching