fix mem overflow