changes to inputs and output to handle inverted inputs. Non-working inputs and outputs.