fixed buffer overflow on too large output