use ternary operator for conditional allocation of nodes