fix events registration bug