use on_database parameter for database id throughout all code, implement save query using tangents and continuations