New codes to deal with the time issue

Hye-Won edited the codes so that the t=inf problem shouldn't happen