fixing some setTimeout issues