refactored to a more modular/react-ish pattern