fixed exists function