fixing out of bounds error