Bug fix to trap exception