Refactor + remove some duplication