replaced all calls to sprintf to snprintf