Refactor $scope variables to services