Add duration parameter, and relevent check.
Add loop deletion.