Finished the window function