Checking for exclude array length before replacing