Added code that may solve whatever issue caused #1 and code that should prevent it from
happening again
Fixed the checking and fixed the exit() being outside the if