Fixing problems with queries not running and problems with the update logic