fix memory error in kaleidoscope