two bugs in total. fixing them to finish the mapper. validated all test cases