rewrite the PCA algo more elegant