refactor .done to .runonce and used variable to refer to current script