fix create_pattern loop; switched x and y in check statement