This isn't anywhere close to how I would have approached it (chaining where clauses) but it looks pretty neat, nice work!