fix bug #8  #21 #20 #11