Fixed JS bug in .ready code