refactored + firebase