An improved finite element formulation derived from the method of weighted residuals