sed was having issues, so changing how replacement is done