implementing zhang's method