fix the order of running in document