refactoring code and tie
refactoring