Adding memory allocation on stack instead of heap