Optimized loop
Fixed has() to use expression engine