bug fix & logging