Added map method to handle custom mapping

Same as the first pull request but with test and documentation.