Preliminary solution (unoptimized)