slightly condensed main cryptosquare function