Refactored function creation to named function to resolve jshint errors