updated exist function