query: moved insert() & update() logic to queries