Minor refactoring on an instance id lookup