Refactored the creation of the service object out of the root view and into a helper function. Security concern to pass the credentials object to a function?