Moved joke selection into a function