replaced sprintf calls with _snprintf calls