fixed #3, fixed #20, fixed #21