adding the timeout function