maping function and better indexing for polygrams