For #9 : refactor to avoid duplicate code