Variable parsing moved to subroutines; passes testing