adding functionality to check move legality