Almost working solution. Reading problems.