add exists(), improve which() and isgroup()