Added duration parameter

I use it in my project and I think it can be useful to other people :)