My attempt at a refactor