Fixed some bugs using the function "snprintf"