added timeout feature