added some constraint checking stuff