Bug fix with exceptions catching