bugfix + redirecting output to log file