refactor firebase events callbacks