refactored original write and absorb code into separate modules