fix timeout function