section B/final

fixed the function