some refactoring
refactoring for #413
fix #413