Fixing wron array indices access