New iteration with a more robust implementation
Add a state class to hold the data
WIP