added functionality for both exercises