avoid side effects when reading the page and simplify the code structure