Fix the bug that will cause timer function fails to restart.