Refactored write to allow offset