Optimized solution for Greplin Challenge 3