Reduced code duplication

@rkorytkowski I changed stuff per your comments https://issues.openmrs.org/browse/OCLM-2