took out code from Controller and placed it in Services