Head reconstruction method to balance flux and source terms in shallow water equations