Realized that only need ifFunctions and command terminals. Simplified code.