refactored $scope