added Exeception handling, fixes #20