Updated script by adding code in else statement