modified for ternary grid
modified for ternary grid
added for ternary grid
added for ternary grid