also computing b of linear system, fixed some issues