some reshuffling to make things more readable