Simplified code significantly, but the issue persists.