Do you want to refactor this code into a private method, as the same code is present in open session and restore session?