refactor the code to be more extendable, with abstraction of Builder class