need to fix setTimeout function