I have just discovered the KeyExist function so will incorporate that into my script also.