remake of lapack functionality