code organization, fixing $scope variables