start replacing main variable with 3 dimentional variable