final version with class changes