updated format selection algorithm