implementation complete as proposed in the jira
code reformatting to match our 2-space indentation