changed z_before to float