new code structure

Refactoring code