fixed issue with exists function