erlang: simplified 'sync' implementation