$ Refactor to make both methods use one piece of code