refactored the code injection for support the persistence keeper callback