get affinity function