Fix timeout function