Refactor lookup a little