Erlang exercise