workable version (with window size adjusted)