query construction implemented