Bug fix in exception handling