refactor offline support