Made cleaner global variable checks with switch statement

Added Switch statement instead of if else