Fix out of bounds error