Fix for: java.lang.ArrayIndexOutOfBoundsException: -1