Corrected logic when testing if  exists.