simplified logic

added some ternary operations