Corrected csa implemenation