script execution order fix