added constraint checking