optimize spy id lookup