refactoring code

Refactoring code and some minor modification…