function works, returns correct answer