Refactor using this in place of $scope