Moved table population to its own function