simplify array operation code