added affinity support