refactoring and more feature support