fix $location undefined error