fixed bug for large window sizes