fix for an index out of bounds error