Rewrite of basic logic to catch any sized ladder logic equation