add legality check