extracting last update logic