spent a day making the speed of the sparse version a bit more acceptable