removed commented code
trap Exceptions and write log to file