working version, but compute_fluxes not tested yet