added logging to stdout and stderr