confirmed correctness with tester