added code to remove fields that are not passed in for templates