use snprintf() instead of sprintf()