New code with changes to allow math equations