Fix a potential bug.
Add assert statement to check the potentical bug.