refactor the code to be a component