Edited codes for exercise 1