refactored long method