refactor update_queries method