Modified comparing of keys to improve efficiency.

Comparing arrays via converting them to JSON is more efficient than using previous approach