This is to refactor the code to composite pattern