fixed #5, fixed #10, fixed #6