Fix exists function