remove some setTimeout and some code clean up