Refactoring using Angular and Firebase