refactored double code