fixed #10 and partial of #4