spped up, but not yet memory efficient.