Commit for 2.2

Made the 1.1 code more generic so the same one can be used for 2.2 as well