refactor to facilitate tests