most constraints functions done
merged