Fixing exceptions handling