development version with dynamically generated SQL queries