fix the bug of  animate indefinitely