Added query based on status