Refactoring code

refactoring