Working solution, needs some cleaning up