Added allocation inside conversion function