Working version, does not use gaussian distribution yet