refactoring for offline support