bug fix and more debug