Improved randomized and added not yet working check for square