a workable version with class decision