adds writing to db