removed asserts and replaced with error messages