updated SQL queries