Changed code to make use of built in Sparse solver