fix timeout function to support msec