Modify events related code, populating selection array, optimizing them