Simplified code, answer to question 3