Efficiency Improved

Terminates for loops early if match is found