Refactor: duplicated code