minor reformat
implemented simple exception handling