fixing sed range end bug