Refactor task5. Need to continue.