Final version of writer implementation