fix task-8 and refactoring task-9