refactor so that it returns position of value, not value