fix memory overflow