added setTimeout but have bugs at line 114