Optimized solution, much quicker lookup