Erlang search problem