removing unnecesary classes - improving the logic