moved out older logic for parsing statements into its own function