small optimizations for accessing a list only once instead of twice