making adjustments to variable names and account for sparse matrices