removed if oldtime
fix loop begin and end
fix loop bug