Refactor the prototype to use Component pattern