Fixed queryn functionality