refactoring to remove redundent and unused code