use snprintf instead of strncpy