refactor nhl query code (mostly complete)