logic now done in sql

old classes are deleted