bugfix in which() method