Changed using float for purity do double due to rounding issues