script execution order corrected