This makes no sense to me - firstly I've no clue what sense the limit switches are (active high or active low) so its unclear what's what.
Secondly you are conflating the two limit switches with each other which is odd - you are either at one limit or at the other, you can't be at both!! I'd expect two clauses, one for limit1, one for limit2. If neither is active nothing should happen, yet this code always does something no matter what.