fix bug #6 #7 #8