fixed OOB error with inversions