Modified to use Eigen library