Remove redundant $ namespace search
Store hit parameters in element objects instead of variables
Improve variable naming and syntax