Refactorring the Lookup and Update function