Refactored week 5.