added free() statement in case not having it represents a memory leak