Use catch/throw to tidy up code