micro optimization with ternary