try to fix the time boundary, fixed for most situation, but still some problem
document the boundary issues in comment