Added ks and plotting