Refactor into smaller components