reworking the problem to better understand the second method