Refactoring: limit code repetitions