changed it to use ternary operators