Using exceptions instead of if statements