You can't use os:timestamp/0 here becuase its not guaranteed to be unique. You'll need to use erlang:now/0.