Rearrange the code to get rid of the second try/catch