Updated Katana solution.