fixed pH logic; small changes to boost efficiency