Recover function improved