Moving functions to global scope
Refactored, service handles data check for correct candidate.