another attempt at dynamic queries