got it to compile but gives wrong answer