Fixed script execution order problem