Fix for bug where phosphorus index would be negative