replaced `setTimeout` as `$timeout`