Fixed an index-out-of-bounds error