Overhauled isLegal method