Use utils.processEvents and replace usage of array with object