Optimized code before adding Chapter Drill functionality