Nested ternaries look horrible, but I guess other implementation would look even worse.