again, I find this a bit ugly - perhaps a QueryBuilder could be used here instead?