Fixed duplicated code. Added a task about error handling.