using mod instead of ternary expression