added restrictions to square creation and class matching