Except of type errors a compileable version of lookup and insert