added some find replace as well as logging to std err