hw5 works as expected