replaced statically allocated buffer with a dynamic one.