refactored code; further refactoring demanded, yet unable to do so.