Fixing readystate error