onreadystatechange logic fix