JS updated with Pairs and methods to make test pass