Small refactor to share code