refactor main and add extract component