Working solution
No big changes