added checking of window size