Fixed functionality to prevent putting yourself in check