add functions for exercise 2.1