fixed the implementation of exists