I need to transform this code into a function so as not to repeat the code. Example below, The main thing that is there would be the validation in the IF, to exchange the ph