fix query-for logic, add typo context
tweaked query-setup to check for index of keys