refactor: reduce duplication