Improve efficiency and add another assert