basic inversion logic redo