updated script after resolving errors