Buy, final step updated to execute queries only one time.