Solution seems to work
Added working solver