fix for IndexOutOfBoundsException