Low-level implementation of pmap function