Fixed an error while event throws false or non array

(cherry picked from commit 3781653fe5762a5ff7d2558f310b81158d0176f9)
Updated check if the event output is an array

(cherry picked from commit aca2861456bb121a750f5cc103149510951b534b)
Fixed an error while element not found event returns false or non array