Changed DEBUG_ON_FLAG to DEBUG_ON_EVENT