is it correct to update the windowSize before doing the actual check ? Should we not only update it after we are sure it is valid ?