changed sprintf to g_snprintf