updated put_data to deal with escape characters