use $timeout instead of setTimeout/$scope.$apply