add assertion / fix out of index error