using snprintf instead of strcat