refactoring : remove some duplicated code