fixed multiple bugs, namely issues with sed