Refactor and implement extra credit.