Optimize to reduce database hits