add function for save and query