refactor to windowing