adapt script and fix order issue