Fix way to calculate quality