convert three query into one