implementation of Gauss-Seidel method