added gamma_w function