logging and bug fix