nit: there shall be a space between catch keyword and the exception variable e.g. 'catch (ex)' (here and below)