code refactory, fix #12m #13m #15