Added query type; Removed unused code