The Elixir/Loglevel exercise behavies strangely

The following implementation passes fine but fails when I move up the last line to the first line !!

defmodule LogLevel do
def to_label(level, legacy?) do
cond do
(legacy? == true) and (level == 0 or level == 5) → :unknown
(legacy? == false) and level == 0 → :trace
(legacy? == false) and level == 5 → :fatal
(legacy? == true or legacy? == false) and level == 1 → :debug
(legacy? == true or legacy? == false) and level == 2 → :info
(legacy? == true or legacy? == false) and level == 3 → :warning
(legacy? == true or legacy? == false) and level == 4 → :error
(level !== 0 or level !== 1 or level !== 2 or level !== 3 or
level !== 4 or level !== 5) → :unknown
end
end
end