Making changes and fixing query