wrong exception being catched