Script or strategy gives different results after refreshing the page (repainting)