added an option to define the timeout