Maybe wrap this in if (data.length % 25 === 0) { .. }  ?