reuse a function that check if limit switch is activted