stable and clean version of writing data to firebase