Problem 44: a little optimization