added $timeout and fix DI bug