implemented function for exercise 11