New implementation with from MPCDemo, now it is a little bit faster.