now handles more exceptions