Separated the script into two processes using a single IF statement to make the program more efficient