Refactor: extract fn