improved window width handling