Used malloc instead of allocating on the stack