Added windowing function and plotting function