Completed part 4 in ruby