Managed to get it working and while performance is much better, syntax is downright disgusting. I know it's Python, but looking at any code written for CQ would give Guido a nightmare. Am not sure looking up to jQuery was a good idea to begin with. I'll try and give it a shot few more times, but boy does code written in this syntax look ugly and cryptic. Thanks for the recommendation though.
Maybe am missing something important here with chaining of commands?