changed queries to be simpler. still tdforitems needs work