Final commit. Exception handling added.