Solution to problem - not fully checked