Changed the if statements to catches, so they're more reliable.