Working code for PCA