add parameter to allow the use of a custom document mapping.
refactor to remove unused parameters.