added changes to logic to account for ties, added ternary operator