updated $timeout

using $timeout instead of setinterval