Add L2 cost function