split up problem12 into several methods