function PCA implementation
working PCA implementation merged