more refactoring and improvement to the writer examples