rewrite saveChapter function