Might be better to wrap the try around the if to prevent duplication