check for i or j being -1, a possible return from methods i and j