changed chain query into nested query.