How can i check for a condition in the if clause and call a function depending on the option chosen by the user