more checks to prevent invalid graphs