Fixed bug in Exists function