Added save query functionality