First fix - inefficient but good enough for testing.