small refactoring in the nasty code