firebase refactor