fix some bugs from  #1