Use $timeout instead of setImmediate