Fixed error-catching bug