refactor writer and remove formatting