implemented timeout logic