remove unused code
some refactoring