Moved microswitch updates to new function. Fixed syntax error