different approach using hash, all test passed for 1, 5 and 10