Made the CCA function working (More code polishing needed)