Getting variable number of chapters correctly