hw4 working version with const parameters