second version.
some exceptions handled