some code refactoring. removed unused code.