fixed the readyState check, tested with testling locally