Finally refactored into a nice pattern