Rewrote program to work without intermediary substitution (but haven't wrote the test and broke the ability to pass in arrays).