working in erlang for looping