removing useless codes, some refactoring