re-write sparse kernel