old function for json