Updated script (refactor)