refactored and renamed