Refactored to have consistent type and func definitions.