refactor Affinity class and include error message for an empty result listing