Issue #262 fixed: convert if condition to assert

As per Shujing Ke's advice, I used the assert instead of if block.