First working version. Sigma is wrong.