* refactor the code to make it more OOP and extensible