fix memory overflow error