added timeout on pulseIn method