fix to looping through classes - it used to stop one too early