Refactored some

the function for reading the state of the inputs is written, untested