before sparse implementation