fixed bug #5 & fixed partly bug #4