use the to_s method for generate_key and clean up the diagonals method