fixing sed call and outputting debug text