Restructure to avoid the heap memory