remove unused code and refactoring