added save code for hashtable and cost