changed to static buffer to avoid malloc