Simplified code and finished task 1