Refactored to avoid repetitions