fixing bugs, fix #15, fix #16