a better fix
fix for ArrayIndexOutOfBoundsException