working version without timeout error