optimize pmap logic to remove frequent method call