Shortened Problem 1 by a couple lines.