refactored the for loop but it is still breaking when checking other illegal blocks in the array