Refactor name lookup