One query to get set of accounts and long-existing logic error.