Improved firebase_update function