fix indentation
add assertion to fix crash in the case that a string is not in the index