adding output path and exception handling