functional
fix 'end' off by one