Refactor the code this feacture