fix to check readyState