My brain starts hurting after about 3 conditionals, here there are 5 (including try).  Is there any way this can be simplified, such as by using some short functions to hide some of the if's ?