added timeout checking