fixed a frezing error caused by an out of bounds error