added conditions for max coordinate and max instruction char