Unoptimized version of ex3