fix memory overrun