move buffer-writer to external module