use function calls instead of ugly cursor.execute