added logging code, but did not test it