adapted processing function, switched to using sprintf instead of strcat