write/3 definition is good. call it for the first time like this: Db1 = db:write(francesco, london, []). [{francesco,london}]. then Db2 = db:write(name2, city2, Db1).