Error catching fix