removed console logs, added $timeout