fixed bug in set_res_phase in line 540 changed z_new to zerr_new