adding code from the first 4 exercises