add Asserts
fix bug