improve recover logic