working on writing to db