Almost completed window function.