Finished the keyExists function