the case where no tabs are inserted. All hail modulus arithmetic. The real fix for this is trivial, but I made a couple of stylistic changes also.