use sprintf+strlen instead of recursive strcat