refactor'd firebase connection to a factory