fixed a typo
some refactoring