changed print from sprintf to snprintf.