re write with Eigen calls.