Final implementation of task-1