some refactoring of task_3
added Docstrings