reduce malloc call to avoid fragment and overhead