Making weighted gradient work in parallel