refactor to use tsq all the way through