refactor working write to db of fb data