Finish hash, search and insert function