Updated to use $scope