optimize the code

Use OOP do design the code and optimize the artitechture