refactoring readwritedma