Fixing bug with event dispatcher