some additions made to sed formatting and substitution