refactored linalg class